/* ----------------------------------------------------------------------------
* File: timer.h
*
* Desc: Timer class
*
* Created: 15/08/2011, by Alexey Korshunov
* ---------------------------------------------------------------------------- */
#ifndef _TIMER_H_
#define _TIMER_H_

#include "error.h"
#include <memory>
#include <windows.h>

namespace Common
{
	typedef void (*fpTimeCallback)(void*);
	struct TimerParams
	{
		TimerParams() 
			: TimeOut(0)
			, TimeCallback(NULL)
			, Parent(NULL)
		{
		}

		DWORD TimeOut;					// milliseconds
		fpTimeCallback TimeCallback;	// callback function
		void* Parent;
	};

	class Timer
	{
	public:
		virtual ~Timer()
		{
		}

		virtual Error Start() = 0;
		virtual Error Stop() = 0;
	};

	std::auto_ptr<Timer> CreateTimer(const TimerParams& params);
}

#endif // _TIMER_H_